1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/**
* Column Definitions for Server Actions
*
* 서버 액션에서 DrizzleTableAdapter가 사용할 컬럼 정의입니다.
* React 컴포넌트 없이 accessorKey만 정의합니다.
*/
import { ColumnDef } from "@tanstack/react-table";
import { TestProduct } from "@/db/schema/test-table-v2";
/**
* 서버 사이드 기능을 위한 컬럼 메타 정보
*/
export interface ServerColumnMeta {
/** 서버에서 GROUP BY 가능 여부 (DB 컬럼에 직접 매핑되어야 함) */
serverGroupable?: boolean;
/** 서버에서 정렬 가능 여부 */
serverSortable?: boolean;
/** 서버에서 필터 가능 여부 */
serverFilterable?: boolean;
}
// === Product Columns (Server-side compatible) ===
// DrizzleTableAdapter는 accessorKey만 사용하므로 cell renderer가 필요 없습니다.
// meta.serverGroupable로 서버 GROUP BY 지원 여부를 표시합니다.
type ProductColumnDef = ColumnDef<TestProduct, any> & { meta?: ServerColumnMeta };
export const productColumnDefs: ProductColumnDef[] = [
{ accessorKey: "id", meta: { serverGroupable: false } }, // PK는 그룹핑 의미 없음
{ accessorKey: "sku", meta: { serverGroupable: false } }, // Unique 값
{ accessorKey: "name", meta: { serverGroupable: false } }, // 이름은 그룹핑 비효율
{ accessorKey: "category", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
{ accessorKey: "price", meta: { serverGroupable: false } },
{ accessorKey: "stock", meta: { serverGroupable: false } },
{ accessorKey: "status", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
{ accessorKey: "isNew", meta: { serverGroupable: true } }, // ✅ 그룹핑 적합
{ accessorKey: "createdAt", meta: { serverGroupable: false } },
{ accessorKey: "updatedAt", meta: { serverGroupable: false } },
];
// === Order Columns for joined data (Pattern 3) ===
// Custom Service에서는 DrizzleTableAdapter를 사용하지 않고 직접 쿼리합니다.
// 조인된 데이터의 컬럼은 단일 테이블에 매핑되지 않기 때문입니다.
export type OrderWithDetails = {
id: number;
orderNumber: string;
quantity: number;
unitPrice: string;
totalAmount: string;
status: string;
orderedAt: Date;
customerName: string | null;
customerEmail: string | null;
customerTier: string | null;
productName: string | null;
productSku: string | null;
};
|